﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.Paint.PaintDuringSimulation.CCoPaintDuringSimulationCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using DnProcessSimulateCommands.Paint.DeleteCoverage;
using DnProcessSimulateCommands.Paint.DisplayCoverage;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.Paint.PaintDuringSimulation;

public class CCoPaintDuringSimulationCmd : TxToggleButtonCommand
{
  private CCoPaintDuringSimulationCmdEnabler m_enabler;

  public virtual bool Licensed => TxCommandLicenser.PaintDuringSimulationLicense;

  public CCoPaintDuringSimulationCmd()
  {
    this.m_enabler = new CCoPaintDuringSimulationCmdEnabler();
    CApPaintDuringSimulationManager.Instance.Initialize();
  }

  public virtual bool Push => CApPaintDuringSimulationManager.Instance.PaintDuringSimulation;

  public virtual string Category => DnProcessSimulateCommands.Paint.PaintDuringSimulation.Resources.StringTable.PAINT_DURING_SIMULATON_CMD_CATAGORY;

  public virtual string Tooltip => DnProcessSimulateCommands.Paint.PaintDuringSimulation.Resources.StringTable.PAINT_DURING_SIMULATON_CMD_TOOLTIP;

  public virtual string Description => DnProcessSimulateCommands.Paint.PaintDuringSimulation.Resources.StringTable.PAINT_DURING_SIMULATON_CMD_DESCRIPTION;

  public virtual void Execute(object cmdParams)
  {
    if (cmdParams is bool)
      return;
    bool usePaintThickness = CApPaintDuringSimulationManager.Instance.UsePaintThickness;
    this.SetPaintDuringSimulationMode();
    if (usePaintThickness == CApPaintDuringSimulationManager.Instance.UsePaintThickness)
    {
      this.Toggle();
      CApPaintDisplayCoverageManager.Instance.StorePaintSettingsToRegistry();
    }
    else
    {
      TxMessageBox txMessageBox = new TxMessageBox();
      if (TxMessageBox.Show(string.Format(DnProcessSimulateCommands.Paint.PaintDuringSimulation.Resources.StringTable.PAINT_DURING_SIMULATION_CHANGE_TYPE_REMOVE_MESSAGE, CApPaintDuringSimulationManager.Instance.UsePaintThickness ? (object) DnProcessSimulateCommands.Paint.PaintDuringSimulation.Resources.StringTable.PAINT_DURING_SIMULATION_CHANGE_TYPE_COVERAGE : (object) DnProcessSimulateCommands.Paint.PaintDuringSimulation.Resources.StringTable.PAINT_DURING_SIMULATION_CHANGE_TYPE_THICKNESS, CApPaintDuringSimulationManager.Instance.UsePaintThickness ? (object) DnProcessSimulateCommands.Paint.PaintDuringSimulation.Resources.StringTable.PAINT_DURING_SIMULATION_CHANGE_TYPE_THICKNESS : (object) DnProcessSimulateCommands.Paint.PaintDuringSimulation.Resources.StringTable.PAINT_DURING_SIMULATION_CHANGE_TYPE_COVERAGE), DnProcessSimulateCommands.Paint.PaintDuringSimulation.Resources.StringTable.PAINT_DURING_SIMULATION_CHANGE_TYPE_REMOVE_CAPTION, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
      {
        CApPaintDeleteCoverageLogic.Instance.DeleteCoverage();
        CApPaintDisplayCoverageManager.Instance.StorePaintSettingsToRegistry();
      }
      else
        CApPaintDuringSimulationManager.Instance.UsePaintThickness = !CApPaintDuringSimulationManager.Instance.UsePaintThickness;
    }
  }

  private void Toggle()
  {
    bool flag = true;
    if (!CApPaintDuringSimulationManager.Instance.PaintDuringSimulation)
    {
      int num = CApPaintDuringSimulationManager.Instance.UsePaintThickness ? 1 : 0;
    }
    if (flag)
      CApPaintDuringSimulationManager.Instance.PaintDuringSimulation = !CApPaintDuringSimulationManager.Instance.PaintDuringSimulation;
    if (CApPaintDuringSimulationManager.Instance.PaintDuringSimulation)
      return;
    CApPaintDuringSimulationManager.Instance.ClearUsingPaintSimulation();
  }

  public virtual string Name => DnProcessSimulateCommands.Paint.PaintDuringSimulation.Resources.StringTable.PAINT_DURING_SIMULATON_CMD_NAME;

  public virtual string Bitmap => "Paint.PaintDuringSimulation.Resources.PaintDuringSimulation.bmp";

  public virtual string LargeBitmap
  {
    get => "Paint.PaintDuringSimulation.Resources.PaintDuringSimulation_BIG.png";
  }

  public virtual ITxCommandEnabler CommandEnabler => (ITxCommandEnabler) this.m_enabler;

  public virtual ITxImage Image
  {
    get => (ITxImage) TxImageManager.GetImageByKey("CoverageDuringSimulation");
  }

  internal virtual void SetPaintDuringSimulationMode()
  {
  }
}
